/**
 * 
 */
package com.jushu.storbox.service;

import android.content.Context;

/**
 * IRemoteFileService remoteFileService = ServiceFactory.getRemoteFileService();
 * IRemoteFolderService remoteFolderService = ServiceFactory.getRemoteFolderService();
 * ILocalFileService localFileService = ServiceFactory.insatnce(context).getLocalFileService();
 * IIlocalFolderService localFolderService = ServiceFactory.insatnce(context).getLocalFolderService();
 * 
 */
public class ServiceFactory {

	private static ServiceFactory instance = new ServiceFactory();

	private static IRemoteFileService remoteFileService = null;

	private static IRemoteFolderService remoteFolderService = null;
	private static IRemoteINodeService remoteINodeService = null;

	private ILocalFileService localFileService = null;

	private IlocalFolderService localFolderService = null;
	
	private ILocalShareFolderService localShareFolderService = null;
	private ILocalShareINodeService localShareINodeService = null;
	private ILocalShareFileService localShareFileService = null;
	private IRemoteShareFileService remoteShareFileService = null;
	private IRemoteShareFolderService remoteShareFolderService = null;
	private IMailListService iMailListService = null;
	private static IMusicService iMusicService=null;
	
	private ITeamSpaceService teamSpaceService = null;
	private ITeamSpaceMemberService teamSpaceMemberService = null;
	
	private static Context context;

	/**
	 * 
	 */
	private ServiceFactory() {
	}

	public static ServiceFactory instance(Context context) {
		ServiceFactory.context = context;
		return instance;
	}
	
	/**
	 * @return
	 */
	public  static IMusicService getMusicService(){
		if(iMusicService==null){
			iMusicService=new MusicService();
		}
		return iMusicService;
	}
	
	/**
	 * @return
	 */
	public static IRemoteFileService getRemoteFileService() {
		if (remoteFileService == null) {
			remoteFileService = new RemoteFileService();
		}
		return remoteFileService;
	}

	/**
	 * @return
	 */
	public static IRemoteFolderService getRemoteFolderService() {
		if (remoteFolderService == null) {
			remoteFolderService = new RemoteFolderService();
		}
		return remoteFolderService;
	}
	
	/**
	 * @return
	 */
	public static IRemoteINodeService getRemoteINodeService() {
		if (remoteINodeService == null) {
			remoteINodeService = new RemoteINodeService();
		}
		return remoteINodeService;
	}

	public ILocalFileService getLocalFileService() {
		if (localFileService == null) {
			localFileService = new LocalFileService();
			this.localFileService.setContext(ServiceFactory.context);
		}
		return localFileService;
	}

	public IlocalFolderService getLocalFolderService() {
		if (localFolderService == null) {
			localFolderService = new LocalFolderService();
			this.localFolderService.setContext(ServiceFactory.context);
		}
		return localFolderService;
	}
	/**
	 * @return
	 */
	public ILocalShareFolderService getLocalShareFolderService() {
		if (localShareFolderService == null) {
			localShareFolderService = new LocalShareFolderService();
			this.localShareFolderService.setContext(ServiceFactory.context);
		}
		return localShareFolderService;
	}
	/**
	 * @return
	 */
	public ILocalShareFileService getLocalShareFileService() {
		if (localShareFileService == null) {
			localShareFileService = new LocalShareFileService();
			this.localShareFileService.setContext(ServiceFactory.context);
		}
		return localShareFileService;
	}
	
	/**
	 * @return
	 */
	public ILocalShareINodeService getLocalShareINodeService() {
		if (localShareINodeService == null) {
			localShareINodeService = new LocalShareINodeService();
			this.localShareINodeService.setContext(ServiceFactory.context);
		}
		return localShareINodeService;
	}
	
	/**
	 * @return
	 */
	public IRemoteShareFileService getRemoteShareFileService() {
		if (remoteShareFileService == null) {
			remoteShareFileService = new RemoteShareFileService();
		}
		return remoteShareFileService;
	}
	
	/**
	 * @return
	 */
	public IRemoteShareFolderService getRemoteShareFolderService() {
		if (remoteShareFolderService == null) {
			remoteShareFolderService = new RemoteShareFolderService();
		}
		return remoteShareFolderService;
	}
	public IMailListService getIamIMailListService()
	{
		if(iMailListService == null)
		{
			iMailListService = new MailListService();
		}
		return iMailListService;
	}

	public ITeamSpaceService getTeamSpaceService()
	{
		if(teamSpaceService == null)
		{
			teamSpaceService = new TeamSpaceService();
		}
		return teamSpaceService;
	}
	
	public ITeamSpaceMemberService getTeamSpaceMemberService()
	{
		if(teamSpaceMemberService == null)
		{
			teamSpaceMemberService = new TeamSpaceMemberService();
		}
		return teamSpaceMemberService;
	}
}
